<template>
  <div style="height:100%;width:100%;position:relative;overflow: hidden;">
      <div class="pagetop" style="border:1px solid #CCC">
          <div class="top-search">
              <table>
                  <tr>
                      <td align="right" width="60">条件代码</td>
                      <td>
                          <el-input v-model="searchParam.searchparam" placeholder="请输入条件代码、条件名称、备注" @keyup.enter.native="searchCondition" clearable style="width: 250px;"></el-input>
                      </td>
                      <td align="right" width="60">使用人</td>
                      <td>
                          <rm-ddl-common datatype="userinfoglobal" dataname="用户" v-model="searchParam.createuser" width="100px" :disabled="utype!='G'" ref="input23" @keyup.enter.native="nextFocus(2, 3)" @change="createuserChange1"></rm-ddl-common>
                      </td>
                  </tr>
              </table>
          </div>
          <div class="top-table">
              <el-button icon="el-icon-search" type="primary" @click="searchCondition" v-has="'PINQUERY'" :disabled="changeflag">查询</el-button>
              <el-button icon="el-icon-plus" @click="MainOpenDialog(1)" v-has="'PADD'" :disabled="changeflag">新增</el-button>
              <el-button icon="el-icon-delete" @click="MainOpenDialog(2)" v-has="'PDELETE'" :disabled="(bPower)?changeflag:true">删除</el-button>
              <el-button icon="el-icon-document" @click="MainOpenDialog(7)" v-has="'PDELETE'" :disabled="!changeflag&&!bPower">保存</el-button>
              <el-button icon="el-icon-refresh-left" @click="RefreshData" v-has="'PDELETE'" :disabled="changeflag">刷新</el-button>
              <el-button icon="el-icon-close" @click="MainOpenDialog(3)" v-has="'PDELETE'" :disabled="!changeflag">取消</el-button>
          </div>
      </div>
      <div class="pagecenter">
          <rm-layout-right splitcolor="#FFFFFF" movingcolor="#CCFFFF" :splitwidth=5 :fixsize=696>
              <div class="pagecenter-left">
                  <vxe-table show-overflow ref="xTable" :data.sync="searchAditionList" class="mytable-style" height="auto" :loading="LabGroupRptItemLoading" :sort-config="{trigger: 'cell'}" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" border size="mini" show-header-overflow highlight-current-row resizable stripe header-align="center" :row-class-name="rowClassName" @current-change="currentChangeEvent">
                      <vxe-table-column field="queryresultno" title="结果条件代码" width="100" align="center"></vxe-table-column>
                      <vxe-table-column field="queryresultname" title="结果条件名称" width="230"></vxe-table-column>
                      <vxe-table-column field="description" title="说明" width="250"></vxe-table-column>
                      <vxe-table-column field="createuser" title="使用人" width="100">
                          <template v-slot="{ row }">
                              <span v-if="row.username">{{row.username}}</span>
                              <span v-if="!row.username">{{row.createuser}}</span>
                          </template>
                      </vxe-table-column>
                  </vxe-table>
              </div>
              <template v-slot:fix>
                  <rm-layout-top splitcolor="#ffffff" :splitwidth=4 :minfixsize="105" :fixsize="105" :canDrag="true">
                      <template v-slot:fix>
                          <div class="pagecenter-right-top">
                              <el-form style="height:100% " :disabled="!bPower">
                                  <table>
                                      <tr>
                                          <td align="right">条件代码</td>
                                          <td>
                                              <el-input v-model="addParam.queryresultno" placeholder="" @input="hasChange" ref="input11" @keyup.enter.native="nextFocus(1, 1)"></el-input>
                                          </td>
                                          <td align="right">条件名称</td>
                                          <td colspan="3">
                                              <el-input v-model="addParam.queryresultname" placeholder="" @input="hasChange" ref="input12" @keyup.enter.native="nextFocus(1, 2)"></el-input>
                                          </td>
                                          <td align="right">使用人</td>
                                          <td>
                                              <rm-ddl-common datatype="userinfoglobal" dataname="用户" v-model="addParam.createuser" width="100px" :disabled="utype!='G'" ref="input13" @keyup.enter.native="nextFocus(1, 3)" @change="createuserChange"></rm-ddl-common>
                                          </td>
                                      </tr>
                                      <tr>
                                          <td align="right" style="vertical-align:top">备注</td>
                                          <td colspan="7">
                                              <el-input type="textarea" v-model="addParam.description" rows="3" @input="hasChange" ref="input14" @keyup.enter.native="nextFocus(1, 4)"></el-input>
                                          </td>
                                      </tr>
                                  </table>
                              </el-form>
                          </div>
                      </template>
                      <div style="height: calc(100% - 40px)">
                          <el-form style="height:100% " :disabled="!bPower">
                              <vxe-table show-overflow ref="nomatch_table" class="mytable-style" :data.sync="searchItemList" height="auto" :loading="rptItemLoading" :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig" :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }" @cell-dblclick="CellDblclick" border size="mini" show-header-overflow highlight-current-row highlight-hover-row resizable stripe header-align="center">
                                  <vxe-table-column field="seq" title="序号" align="center" width="55" :edit-render="{name: 'input', events: {change: hasChange}}" sortable></vxe-table-column>
                                  <vxe-table-column field="rpt_itemname" title="报告项目(双击弹窗)" width="250" :edit-render="{name:'input', autoselect: true, attrs: {readonly: true}}" sortable></vxe-table-column>
                                  <!-- <vxe-table-column field="rpt_itemname" title="报告项目(双击弹窗)" width="145" sortable>
                                  <template v-slot="{row}">
                                      <rm-ddl-rptitem :appendtobody="true" @change="rptitemchange($event,row)" v-model="row.rpt_itemname" width="190px"></rm-ddl-rptitem>
                                  </template>
                              </vxe-table-column> -->
                                  <vxe-table-column field="resistrules" title="耐药机制" width="120" :edit-render="{type: 'default'}">
                                      <template v-slot="{ row }">
                                          <el-select v-model="row.resistrules"  @dblclick.native="popMultipleChk(row.resistrules, 'resistrules', rescodeOption, '耐药机制选择')" style="width: 100%;" filterable clearable>
                                              <el-option v-for="(item, index) in rescodeOption" :key="index" :value="item.data" :label="item.display"> </el-option>
                                          </el-select>
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="lowlimit" title="数值结果<" width="90" :edit-render="{name: 'input', events: {change: hasChange}, attrs: {readonly: !bPower}}" sortable></vxe-table-column>
                                  <vxe-table-column field="uplimit" title="数值结果>" width="90" :edit-render="{name: 'input', events: {change: hasChange}, attrs: {readonly: !bPower}}" sortable></vxe-table-column>
                                  <vxe-table-column field="txtoperator" title="文字结果条件" width="95" sortable>
                                      <template v-slot="{ row }">
                                          <el-select v-model="row.txtoperator" placeholder="请选择" @change="hasChange" :disabled="!bPower">
                                              <el-option v-for="item in txtoperatorOptions" :key="item.value" :label="item.label" :value="item.value">
                                              </el-option>
                                          </el-select>
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="txtresults" title="文字结果（多个,隔开）" width="140" :edit-render="{name: 'input'}" sortable></vxe-table-column>
                                  <vxe-table-column field="txtlike" sortable title="文字模糊匹配" width="150" align="center">
                                      <template v-slot="{ row }">
                                          <el-checkbox v-model="row.txtlike" true-label="1" false-label="0" @change="hasChange"></el-checkbox>
                                      </template>
                                  </vxe-table-column>
                                  <vxe-table-column field="mustinclude" title="必选条件" width="170" align="center">
                                      <template v-slot="{ row }">
                                          <el-checkbox v-model="row.mustinclude" true-label="1" false-label="0" @change="hasChange"></el-checkbox>
                                      </template>
                                  </vxe-table-column>

                              </vxe-table>
                          </el-form>
                          <div class="detail-operation">
                              <el-form style="height:100% " :disabled="!bPower">
                                  <el-button icon="el-icon-plus" @click="MainOpenDialog(4)" v-has="'PADD'">新增明细</el-button>
                                  <el-button icon="el-icon-caret-top" @click="MainOpenDialog(5)" v-has="'PDELETE'">插入明细</el-button>
                                  <el-button icon="el-icon-delete" @click="MainOpenDialog(6)" v-has="'PDELETE'">删除明细</el-button>
                                  <el-button icon="el-icon-document-copy" @click="MainOpenDialog(8)" v-has="'PDELETE'">复制明细</el-button>
                                  <el-button icon="el-icon-document-add" @click="MainOpenDialog(9)" v-has="'PDELETE'">粘贴明细</el-button>
                              </el-form>
                          </div>
                      </div>
                  </rm-layout-top>
              </template>
          </rm-layout-right>
      </div>
      <el-dialog width="1000px" top="10px" :append-to-body="true" :close-on-click-modal="false" title="选择报告项目" :visible.sync="rpt_itemdialog" :destroy-on-close="true">
          <rm-pop-rptitem prgno="LIS156" @cancel="rpt_itemdialog=false;" :isAllRpt="1" @selitem="rpt_itemchange" :rptunitid="txtrptunit"></rm-pop-rptitem>
      </el-dialog>
      <el-dialog width="900px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="耐药机制选择" :visible.sync="dialogMultipleVisible" :destroy-on-close="true">
          <rm-SqlMultiple :leftOption="option1" :rightOption="option2" :name="fieldname" @change="closedialog"></rm-SqlMultiple>
      </el-dialog>
  </div>
</template>

<script>
import XEUtils from "xe-utils";
export default {
  name: "LIS156",
  data() {
      return {
          LabGroupRptItemLoading: false,
          rptItemLoading: false,
          txtrptunit: "",
          coverflag: false,
          searchAditionList: [],
          fSearchAditionList: [],
          searchItemList: [],
          fSearchItemList: [],
          keyConfig: {
              isDel: true,
              isTab: true,
              isEdit: true,
          },
          keyLocalConfig: {
              isArrow: true,
          },
          searchParam: {},
          addParam: {}, // 新增 修改 字段
          faddParam: {},
          operatetype: 2, //1:新增 2:修改 3:删除
          changeflag: false,
          utype: "",
          loginuserno: "",
          bPower: true,
          selrow: {},
          selrow2: {},
          txtoperatorOptions: [
              {
                  value: "In",
                  label: "等于",
              },
              {
                  value: "NotIn",
                  label: "不等于",
              },
          ],
          rpt_itemdialog: false,
          //耐药机制
          rescodeOption: [],
          dialogMultipleVisible:false,
          option1: [],
          option2: [],
          fieldname:"",
          clipboardContent: [],
      };
  },
  created() {
      this.initOption()
      this.loginUser();
      this.QueryGroupSearch();
  },
  mounted() {},
  methods: {
      // 判断登录人员
      loginUser() {
          this.utype = this.$tool.getSession(this.$tool.loginutype);
          this.loginuserno = this.$tool.getSession(this.$tool.loginuserno);
          if (this.utype == "G") {
              this.addParam.createuser = "_Global_";
          } else {
              this.addParam.createuser = this.$tool.getSession(this.$tool.loginusername);
          }
      },
      async initOption() {
          try {
              const res = await this.$tool.request({
                  url: "LIS/LIS1/LIS156",
                  method: "post",
                  data: {
                      action: "getOption",
                  },
              })
              // this.deptgroupOption = res.deptgroupOption
              // this.germcombOption = res.germcombOption
              // this.pattypeOption = res.pattypeOption
              // this.deptOption = res.deptOption
              // this.hospOption = res.hospOption
              // this.doctorOption = res.doctorOption
              // this.rptunitOption = res.rptunitOption
              // this.rptunitGroupOption = res.rptunitGroupOption
              // this.reportcommOption = res.reportcommOption
              // this.wardOption = res.wardOption
              // this.labgroupOption = res.labgroupOption
              // this.specimenOption = res.specimenOption
              // this.userOption = res.userOption
              this.rescodeOption = res.rescodeOption
          } catch (e) {
              this.$message.warning(e)
          }
      },
      //查询条件
      QueryGroupSearch() {
          var userno = this.$tool.getSession(this.$tool.loginuserno);
          if (userno) {
              this.LabGroupRptItemLoading = true;
              this.$tool
                  .request({
                      url: "LIS/LIS1/LIS156",
                      method: "post",
                      data: {
                          action: "querygroupsearch",
                          ...this.searchParam,
                      },
                  })
                  .then((response) => {
                      this.LabGroupRptItemLoading = false;
                      // 根据检验组查询 Lab_Group_RptItem 表的数据
                      this.fSearchAditionList = XEUtils.clone(response.Data, true);
                      this.searchAditionList = response.Data;
                      if (response.Data != null && response.Data.length > 0) {
                          this.faddParam = XEUtils.clone(response.Data[0], true);
                          this.addParam = XEUtils.clone(response.Data[0], true);
                          this.selrow = response.Data[0];
                          this.$refs.xTable.setCurrentRow(this.selrow);
                          if (this.selrow.createuser != this.loginuserno && this.utype != "G") {
                              this.bPower = false;
                          } else {
                              this.bPower = true;
                          }
                          this.QuerySearchItemList(this.selrow.queryresultno);
                      } else {
                          this.fSearchItemList = [];
                          this.searchItemList = [];
                      }
                  })
                  .catch((e) => {
                      console.log("error", e);
                  });
          }
      },
      // 查询默认报告单元
      QuerySearchItemList(queryresultno) {
          this.rptItemLoading = true;
          this.$tool
              .request({
                  url: "LIS/LIS1/LIS156",
                  method: "post",
                  data: {
                      action: "querysearchitem",
                      queryresultno: queryresultno,
                  },
              })
              .then((response) => {
                  this.rptItemLoading = false;
                  this.fSearchItemList = XEUtils.clone(response.Data, true);
                  this.searchItemList = response.Data;
                  if (response.Data.length > 0) {
                      this.$refs.nomatch_table.setCurrentRow(response.Data[0]);
                  }
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },
      currentChangeEvent(e) {
          if (this.changeflag) {
              // 点击切换之前的 row
              this.$refs.xTable.setCurrentRow(this.selrow);
              return false;
          }
          this.selrow = e.row;
          if (this.selrow.createuser != this.loginuserno && this.utype != "G") {
              this.bPower = false;
          } else {
              this.bPower = true;
          }
          this.faddParam = XEUtils.clone(e.row, true);
          // this.addParam = e.row;
          this.addParam = XEUtils.clone(e.row, true);
          // var rowIndex = e.rowIndex;
          this.QuerySearchItemList(this.selrow.queryresultno);
      },
      MainOpenDialog(k) {
          if (k == 1) {
              // 新增
              this.operatetype = 1;
              this.hasChange();
              this.$refs["input11"].focus();
              this.addParam = {};
              this.searchItemList = [];
              this.loginUser();
              this.bPower = true;
          }
          if (k == 2) {
              var that = this;
              that.$confirm("你确定删除这条记录?", "提示", {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
              }).then(() => {
                  that.operatetype = 3;
                  that.$tool
                      .request({
                          url: "LIS/LIS1/LIS156",
                          method: "post",
                          data: {
                              action: "addsearchadition",
                              addparam: that.addParam,
                              utype: that.operatetype,
                          },
                      })
                      .then((response) => {
                          if (response.errcode != "1") {
                              that.$message({
                                  message: "保存失败！" + response.errmsg,
                                  type: "warning",
                              });
                          } else {
                              that.$message({
                                  message: response.errmsg,
                                  type: "success",
                              });
                              // that.QueryGroupSearch();
                              that.changeflag = false;
                              that.operatetype = 2;
                              // 删除不刷新表格
                              var delrow = this.$refs.xTable.getCurrentRow();
                              var alld = this.$refs.xTable.getTableData().fullData;
                              var rowindex = alld.indexOf(delrow);
                              this.$refs.xTable.remove(delrow);
                              let havedata = this.$refs.xTable.getTableData().fullData;
                              if (havedata.length > 0) {
                                  if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                                  this.fSearchAditionList = XEUtils.clone(havedata, true);
                                  this.faddParam = XEUtils.clone(havedata[rowindex], true);
                                  this.addParam = XEUtils.clone(havedata[rowindex], true);
                                  let selectrow = havedata[rowindex];
                                  this.$refs.xTable.setCurrentRow(selectrow);
                                  if (this.selectrow.createuser != this.loginuserno && this.utype != "G") {
                                      this.bPower = false;
                                  } else {
                                      this.bPower = true;
                                  }
                                  this.QuerySearchItemList(selectrow.queryresultno);
                              }
                          }
                      })
                      .catch((e) => {});
              });
          }
          if (k == 3) {
              // 取消
              this.operatetype = 2;
              this.changeflag = false;
              this.searchAditionList = this.fSearchAditionList;
              this.addParam = XEUtils.clone(this.faddParam, true);
              this.searchItemList = XEUtils.clone(this.fSearchItemList, true);
              this.$nextTick(() => {
                  this.$refs.xTable.setCurrentRow(this.addParam);
                  if (this.addParam.createuser != this.loginuserno && this.utype != "G") {
                      this.bPower = false;
                  } else {
                      this.bPower = true;
                  }
              });
          }
          if (k == 4) {
              this.$refs.nomatch_table
                  .insert({
                      queryresultno: this.addParam.queryresultno,
                      seq: this.$refs.nomatch_table.tableFullData.length > 0 ? (Math.floor(this.$refs.nomatch_table.tableFullData[this.$refs.nomatch_table.tableFullData.length - 1].seq / 10) + 1) * 10 : 10,
                      txtoperator: "In",
                      txtlike: 0,
                      mustinclude: 0,
                  })
                  .then(({ row }) => {
                      this.$nextTick(() => {
                          this.$refs.nomatch_table.setCurrentRow(row);
                      });
                  });
              this.hasChange();
          }
          if (k == 5) {
              var newRow = {
                  queryresultno: this.addParam.queryresultno,
                  seq: this.$refs.nomatch_table.tableFullData.length > 0 ? (Math.floor(this.$refs.nomatch_table.tableFullData[this.$refs.nomatch_table.tableFullData.length - 1].seq / 10) + 1) * 10 : 10,
                  txtoperator: "In",
                  txtlike: 0,
                  mustinclude: 0,
              };
              let row = this.$refs.nomatch_table.getCurrentRow();
              var havedata = this.$refs.nomatch_table.getTableData().fullData;
              if (row && havedata.length > 0) {
                  newRow.seq = (row.seq / 10 - 1) * 10;
                  this.$refs.nomatch_table.insertAt(newRow, row).then(({ row }) => {
                      this.$nextTick(() => {
                          this.$refs.nomatch_table.setCurrentRow(row);
                          this.$refs.nomatch_table.setActiveRow(row);
                      });
                  });
              } else {
                  this.$refs.nomatch_table.insert(newRow).then(({ row }) => {
                      this.$nextTick(() => {
                          this.$refs.nomatch_table.setCurrentRow(row);
                          this.$refs.nomatch_table.setActiveRow(row);
                      });
                  });
              }
              this.hasChange();
          }
          if (k == 6) {
              var delrow = this.$refs.nomatch_table.getCurrentRow();
              var havedata = this.$refs.nomatch_table.getTableData().fullData;
              if (delrow && havedata.length > 0) {
                  var rowindex = havedata.indexOf(delrow);
                  this.$refs.nomatch_table.remove(delrow);
                  if (havedata.length > 0) {
                      if (rowindex >= havedata.length) rowindex = havedata.length - 1;
                      let selectrow = havedata[rowindex];
                      this.$refs.nomatch_table.setCurrentRow(selectrow);
                  }
                  this.hasChange();
              } else {
                  this.$message({
                      message: "请先选中要删除的明细！",
                      type: "warning",
                  });
              }
          }
          if (k == 7) {
              // 保存
              this.SaveSearchCondition();
          }
          if (k == 8) {
              // 复制
              var havedata = this.$refs.nomatch_table.getTableData().fullData;
              if(havedata.length > 0 ){
                  this.clipboardContent = XEUtils.clone(havedata);
                  this.$message({
                      message: "复制所有明细成功！",
                      type: "success",
                  });
              }else{
                  this.$message({
                      message: "未找到需要复制的明细！",
                      type: "warning",
                  });
              }
          }
          if (k == 9) {
              // 粘贴
              if(this.clipboardContent.length > 0){
                  this.clipboardContent.forEach((element, index) => {
                      this.$refs.nomatch_table.insert({
                          queryresultno: element.queryresultno,
                          seq: this.$refs.nomatch_table.tableFullData.length > 0 ? (Math.floor(this.$refs.nomatch_table.tableFullData[this.$refs.nomatch_table.tableFullData.length - 1].seq / 10) + 1) * 10 : 10,
                          rpt_itemcode: element.rpt_itemcode,
                          uplimit: element.uplimit,
                          lowlimit: element.lowlimit,
                          txtresults: element.txtresults,
                          txtoperator: element.txtoperator,
                          txtlike: element.txtlike,
                          mustinclude: element.mustinclude,
                          resistrules: element.resistrules,
                          rpt_itemname: element.rpt_itemname,
                      }).then(({ row }) => {
                          this.$nextTick(() => {
                              this.$refs.nomatch_table.setCurrentRow(row);
                          });
                      });;
                  });
                  this.hasChange();
              }else{
                  this.$message({
                      message: "无明细粘贴，请先点击复制明细！",
                      type: "warning",
                  });
              }
          }
      },
      hasChange() {
          this.changeflag = true;
      },
      rowClassName({ row, rowIndex }) {
          let isDirty = this.$refs.xTable.hasRowChange(row);
          if (isDirty) {
              return "row-modify";
          }
          if (this.$refs.xTable.hasRowInsert(row)) return "row-new";
      },
      // 使用人修改
      createuserChange(code, name) {
          this.addParam.createuser = code;
          this.addParam.username = name;
          this.changeflag = true;
      },
      createuserChange1(code, name) {
          this.searchParam.createuser = code;
          this.searchParam.username = name;
      },
      CellDblclick({ row, column }) {
          // 报告项目弹窗
          if (column.property == "rpt_itemname") {
              this.selrow2 = row;
              this.rpt_itemdialog = true;
              this.changeflag = true;
          }
      },
      rpt_itemchange(code, name) {
          this.selrow2.rpt_itemcode = code;
          this.selrow2.rpt_itemname = name+'['+code+']';
          this.rpt_itemdialog = false;
      },
      // 存盘
      SaveSearchCondition() {
          if (this.addParam.queryresultno == undefined || this.addParam.queryresultno == "") {
              this.$alert("请输入条件代码", "信息", {
                  confirmButtonText: "确定",
                  callback: (action) => {},
              });
              return false;
          }
          if (this.addParam.queryresultno == undefined || this.addParam.queryresultno == "") {
              this.$alert("请输入条件名称", "信息", {
                  confirmButtonText: "确定",
                  callback: (action) => {},
              });
              return false;
          }
          // 排序
          this.$refs.nomatch_table.tableFullData.sort((a, b) => {
              return a.seq - b.seq;
          });
          this.$refs.nomatch_table.tableFullData.forEach((element, index) => {
              element.seq = (index + 1) * 10;
          });
          var nomatch_tableChangeFlag = false;
          var getRecord = this.$refs.nomatch_table.getRecordset();
          if (getRecord.insertRecords.length > 0 || getRecord.removeRecords.length > 0 || getRecord.updateRecords.length > 0) {
              nomatch_tableChangeFlag = true;
          }
          if (this.faddParam.queryresultno != this.addParam.queryresultno) {
              if (this.$refs.nomatch_table.tableFullData.length > 0) {
                  this.$refs.nomatch_table.tableFullData.forEach((element) => {
                      element.queryresultno = this.addParam.queryresultno;
                  });
              }
          }
          if (this.$tool.getSession(this.$tool.loginutype) != "G") {
              this.addParam.createuser = this.$tool.getSession(this.$tool.loginuserno);
          }
          // 保存
          this.$tool
              .request({
                  url: "LIS/LIS1/LIS156",
                  method: "post",
                  data: {
                      action: "addsearchadition",
                      addparam: this.addParam,
                      OformData: this.operatetype == 1 ? "" : this.faddParam,
                      queryresultnochange: this.$refs.nomatch_table.tableFullData,
                      upt: nomatch_tableChangeFlag ? this.$refs.nomatch_table.tableFullData : "",
                      utype: this.operatetype,
                  },
              })
              .then((response) => {
                  if (response.errcode != "1") {
                      this.$message({
                          message: "保存失败！" + response.errmsg,
                          type: "warning",
                      });
                  } else {
                      this.$message({
                          message: response.errmsg,
                          type: "success",
                      });
                      // this.QueryGroupSearch();
                      this.QuerySearchItemList(this.addParam.queryresultno);
                      this.changeflag = false;
                      if (this.operatetype == 1) {
                          // 新增不更新表格操作
                          setTimeout(() => {
                              this.$refs.xTable.insertAt(this.addParam, -1);
                              var index = this.$refs.xTable.getTableData().fullData.length - 1;
                              this.faddParam = XEUtils.clone(this.$refs.xTable.getTableData().fullData[index], true);
                              this.addParam = this.$refs.xTable.getTableData().fullData[index];
                              this.$refs.xTable.setCurrentRow(this.$refs.xTable.getTableData().fullData[index]);
                              if (this.$refs.xTable.getTableData().fullData[index].createuser != this.loginuserno && this.utype != "G") {
                                  this.bPower = false;
                              } else {
                                  this.bPower = true;
                              }
                              this.selrow = this.$refs.xTable.getCurrentRow();
                          }, 20);
                          this.operatetype = 2;
                          return false;
                      }
                      if (this.operatetype == 2) {
                          var that = this;
                          var alld = that.$refs.xTable.getTableData().fullData;
                          var rowIndex = alld.indexOf(that.selrow);
                          let promise = new Promise(function (resolve, reject) {
                              Object.keys(that.addParam).forEach((key) => {
                                  that.$refs.xTable.getTableData().fullData[rowIndex][key] = that.addParam[key];
                              });
                              resolve();
                          });
                          promise.then(() => that.$refs.xTable.setCurrentRow(that.$refs.xTable.getTableData().fullData[rowIndex]));
                          if (that.$refs.xTable.getTableData().fullData[rowIndex].createuser != that.loginuserno && this.utype != "G") {
                              that.bPower = false;
                          } else {
                              that.bPower = true;
                          }
                          that.faddParam = XEUtils.clone(that.addParam, true);
                      }
                  }
              })
              .catch((e) => {});
      },
      RefreshData() {
          this.searchParam = {};
          // this.searchParam.likeflag = 0;
          this.QueryGroupSearch();
      },
      searchCondition() {
          this.faddParam = {};
          this.addParam = {};
          this.loginUser();
          this.QueryGroupSearch();
      },
      // 回车切换输入框
      nextFocus(id, index) {
          if (index <= 3) {
              var that = this;
              var focusIndex = index + 1;
              setTimeout(function () {
                  if (index == 3) {
                      that.$refs["input" + id + index].$refs.ddlmainSelect.blur();
                  }
                  that.$refs["input" + id + focusIndex].focus();
              }, 1);
          }
      },
      popMultipleChk(e, fieldname, option, title) {
          let temp = XEUtils.clone(option, true)
          this.option1 = []
          this.option2 = []
          if (e != "") {
              let k = e.split(",")
              k.forEach((item) => {
                  let ndata = temp.find((m) => m.data == item)
                  if (ndata != undefined && ndata != null) {
                      this.option2.push(ndata)
                  }
              })
              temp.forEach((item) => {
                  if (k.indexOf(item.data + "") < 0) {
                      this.option1.push(item)
                  }
              })
          } else {
              this.option1 = temp
          }
          this.fieldname = fieldname
          this.dialogMultipleVisible = true
      },
      closedialog(value, name) {
          console.log(value,name);
          if (value != "close") {
              let row = this.$refs.nomatch_table.getCurrentRow();
              if(row){
                  row.resistrules=value;
              }
          }
          this.dialogMultipleVisible = false
      },
  },
};
</script>

<style scoped>
.pagetop {
  width: 100%;
  height: 38px;
  border: 1px solid #ccc;
  position: absolute;
  font-size: 12px;
  display: flex;
  padding: 5px 0;
  line-height: 24px;
}
.top-search {
  flex: 1;
}
.pagetop .top-table {
  padding: 0px 2px 0px 5px;
  margin: 2px 0;
  /* position: absolute; */
  right: 5px;
  text-align: right;
}
.pagecenter {
  position: absolute;
  top: 43px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}
.pagecenter-left {
  height: 100%;
}
.pagecenter-right-top {
  width: 100%;
  border: 1px solid #ccc;
  height: 100%;
  min-height: 100px;
}
.pagecenter-right-top table {
  font-size: 12px;
  width: 100%;
  border-spacing: 5px;
}
.detail-operation {
  display: flex;
  padding: 0px 2px 0px 5px;
  margin: 5px 0;
}
::v-deep .middle-center tr td div .el-input__inner {
  border: 1px solid rgba(255, 254, 254, 0) !important;
  background-color: rgba(255, 254, 254, 0) !important;
}
::v-deep  .el-input.is-disabled .el-input__inner {
  color: #000000 !important;
}
::v-deep  .el-textarea .el-textarea__inner {
  width: 96.5% !important;
}
::v-deep  .el-textarea__inner {
  padding: 2px 5px !important;
}
::v-deep  .el-button.is-disabled {
  border: 0px;
  color: grey;
  background-color: #e6e6e6;
  font-weight: normal;
}
::v-deep  .pagecenter-left tr.vxe-body--row.row-new {
  color: #cc6600;
}
::v-deep  .pagecenter-left tr.vxe-body--row.row-modify {
  color: blue !important;
}
</style>
